#include<bits/stdc++.h>

using namespace std;
int Q[1000], head = 0, tail = -1;//Q[head,tail]
int main() {
    int a[] = {6, 3, 1, 7, 5, 8, 9, 2, 4};
    for (int i = 0; i < 9; i++)Q[++tail] = a[i];
    while (head <= tail) {
        cout << Q[head++] << " ";
        if (head > tail)break;
        int x = Q[head++];
        Q[++tail] = x;

    }
    return 0;
}
